#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <curl/curl.h>
#include <curl/easy.h>

#define songid "528272202"

FILE *fp; 

size_t write_data_file(void *ptr, size_t size, size_t nmemb, void *stream)
{
    int written = fwrite(ptr, size, nmemb, (FILE *)fp);
    return written;
}

int main()
{
    CURL *curl;

    curl_global_init(CURL_GLOBAL_ALL);
    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, 
    "http://music.163.com/api/song/detail/?id=" songid "&ids=%5B" songid "%5D");

    if ((fp = fopen("./a.html", "w")) == NULL)
    {
        curl_easy_cleanup(curl);
        exit(1);
    }
    //CURLOPT_WRITEFUNCTION
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_file);
    curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    exit(0);
}